package com.sh.rabbitmq;

import com.rabbitmq.client.CancelCallback;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;
import com.sh.rabbitmq.utils.ChannelFactory;

public class Consumer {

    public static final String QUEUE_NAME = "hello";

    public static void main(String[] args) throws Exception {
        Channel channel = ChannelFactory.getChannel();


        DeliverCallback deliverCallback = (var1,var2)->{
            System.out.println("接收到的消息："+ new String(var2.getBody()));
        };

        CancelCallback cancelCallback = var1 ->{
            System.out.println("回调了");
        };

        System.out.println("C3正在等待接收");
        channel.basicConsume(QUEUE_NAME,true,deliverCallback,cancelCallback);
    }
}
